package cc.fs.study.keyboard;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import java.lang.ref.WeakReference;

import cc.fs.study.R;
import cc.fs.study.utils.KeyboardVisibilityEvent;

public class KeyboardActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_keyboard);

        KeyboardVisibilityEvent.setEventListener(new WeakReference<Activity>(this), new KeyboardVisibilityEvent.KeyboardVisibilityEventListener() {
            @Override
            public void onVisibilityChanged(boolean isOpen) {
                if(isOpen){
                    Toast.makeText(getApplicationContext(),"键盘显示",Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getApplicationContext(),"键盘隐藏",Toast.LENGTH_SHORT).show();
                }
            }
        });

    }
}
